#include<iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#define N 100
int main() {
    int n, m[N], i;
    cin >> n;
    for (i = 0; n; i++) {
        m[i] = n % 6;
        n = n / 6;
    }
    for (i--; i >= 0; i--) {
        cout << m[i];
    }
    cout << endl;
    return 0;
}
